#include <iostream>
#include <vector>
#include <queue>

int direction_vec[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

struct nodeInfo
{
    int x;
    int y;
    int step;
};

void bfs(std::vector<std::vector<int>> &peak_map,
         std::vector<std::vector<bool>> &peak_visited,
         int k, int &min_step, int &max_height)
{
    int col = peak_map[0].size();
    int row = peak_map.size();

    nodeInfo fn = {0, 0, 0};
    peak_visited[0][0] = true;
    std::queue<nodeInfo> nq;
    nq.push(fn);

    while (!nq.empty())
    {
        auto nd = nq.front();
        nq.pop();
        if (max_height < peak_map[nd.y][nd.x])
        {
            min_step = nd.step;
            max_height = peak_map[nd.y][nd.x];
        }

        for (int i = 0; i < 4; i++)
        {
            int y = nd.y + direction_vec[i][0];
            int x = nd.x + direction_vec[i][1];
            if (x >= 0 && x < col && y >= 0 && y < row && !peak_visited[y][x] &&
                abs(peak_map[y][x] - peak_map[nd.y][nd.x]) <= k)
            {
                std::cout << y << " " << x << " " << peak_map[y][x] << " " << peak_map[nd.y][nd.x] << std::endl;
                nq.push({x, y, nd.step + 1});
                peak_visited[y][x] = true;
            }
        }
    }
}

int main()
{
    int m, n, k;
    std::cin >> m >> n >> k;

    std::vector<std::vector<int>> peak_map(m, std::vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            std::cin >> peak_map[i][j];
        }
    }

    std::vector<std::vector<bool>> peak_visited(m, std::vector<bool>(n, false));

    int min_step = 0;
    int max_height = 0;
    std::cout << std::endl;
    bfs(peak_map, peak_visited, k, min_step, max_height);
    std::cout << min_step << " " << max_height << std::endl;
    return 0;
}